package com.zjj.learn.algorithmPlus.util;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @author zjj_admin
 */
public class Util {


    public static <R> void assertEquals(R expect, R actual) {
        if (!expect.equals(actual)) {
            throw new RuntimeException("assertEquals...异常" + "expect：" + expect + "  actual：" + actual);
        }
    }

    /**
     * 获取方法执行时间，单位 纳秒（ns）
     *
     * @param supplier
     * @param <T>
     * @return
     */
    public static <T> long runningTime(Supplier<T> supplier) {
        long startTime = System.nanoTime();
        supplier.get();
        long endTime = System.nanoTime();
        return (endTime - startTime);
    }
}
